#include <iostream>
#include <cstring>
using namespace std;
const int N = 1001;
int dp[N];//用来存放在 i g中的最大质量
int w[7]={0,1,2,3,5,10,20};//砝码质量
int m[7];//用来存放砝码的数量
int new_w[N];//用来存放拆分后砝码的质量

int main(){
    int Total = 0;//答案
    int sum = 0;//此为背包的最大载重
    for (int i = 1; i <= 6; i++) {
        cin >> m[i];
        sum += m[i] * w[i];//昨晚把w[i]写成了i 🤦‍
    }

    memset(dp, 0, sizeof(dp));
    
    int new_n = 0;//用来记录拆分后的数量

    for (int i = 1; i <= 6; i++) {
        for (int j = 1; j <= m[i]; j <<= 1) {
            m[i]-=j;
            new_w[++new_n] = j * w[i];
        }
        if (m[i]) {
            new_w[++new_n] = m[i] * w[i];
        }
    }


    for (int i = 1; i <=new_n; i++) {
        for (int j = sum; j >= new_w[i]; j--) {
            dp[j] = max(dp[j], dp[j - new_w[i]] + new_w[i]);

        }
    }
    for (int i = 1; i <= sum; i++) {
        if (dp[i] == i) Total++;
    }
    cout <<"Total=" << Total;
    return 0;
}